home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form frm3DFloor
- Caption = "The 3D Floor Program"
- ClientHeight = 4230
- ClientLeft = 1095
- ClientTop = 1815
- ClientWidth = 6720
- Height = 4920
- Icon = "3DFLOOR.frx":0000
- Left = 1035
- LinkTopic = "Form1"
- MaxButton = 0 'False
- ScaleHeight = 4230
- ScaleWidth = 6720
- Top = 1185
- Width = 6840
- Begin VB.Timer Timer1
- Interval = 400
- Left = 3000
- Top = 2520
- End
- Begin FloorLibCtl.Floor Floor1
- Left = 3000
- Top = 1800
- _version = 65536
- _extentx = 741
- _extenty = 741
- _stockprops = 0
- End
- Begin VB.Menu mnuFile
- Caption = "&File"
- Begin VB.Menu mnuExit
- Caption = "E&xit"
- End
- End
- Begin VB.Menu mnuHelp
- Caption = "&Help"
- Begin VB.Menu mnuAbout
- Caption = "&About..."
- End
- End
- Attribute VB_Name = "frm3DFloor"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- ' All variables must be declared.
- Option Explicit
- Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
- Select Case KeyCode
-
- Case 37, 100
- 'Left key (37) or 4 key (100) was pressed.
- Floor1.Angle = Floor1.Angle + 6
-
- Case 39, 102
- 'Right key (39) or 6 key (102) was pressed.
- Floor1.Angle = Floor1.Angle - 6
-
- Case 38, 104
- 'Up key (38) or 8 key (104) was pressed.
- Floor1.Advance 40
-
- Case 40, 98
- 'Down key (40) or 2 key (98) was pressed.
- Floor1.Advance -40
- End Select
- ' Display the 3D view.
- Floor1.Display3D
- End Sub
- Private Sub Form_Load()
- Dim OpenResult As Integer
- Dim Message As String
- Dim Path As String
- ' Get the name of the directory where the
- ' program resides.
- Path = App.Path
- If Right(Path, 1) <> "\" Then
- Path = Path + "\"
- End If
- ' Open the FLOOR50.FLR file.
- Floor1.filename = Path + "FLOOR50.FLR"
- Floor1.hWndDisplay = Me.hWnd
- Floor1.NumOfRows = 50
- Floor1.NumOfCols = 50
- OpenResult = Floor1.Open
- ' If FLR file could not be opened, terminate
- ' the program.
- If OpenResult <> 0 Then
- Message = "Unable to open file: " + Floor1.filename
- Message = Message + Chr(13) + Chr(10)
- Message = Message + "Error Code: " + Str(OpenResult)
- MsgBox Message, vbCritical, "Error"
- End
- End If
- ' Set the initial user's position and viewing angle.
- Floor1.X = 4 * Floor1.CellWidth
- Floor1.Y = 4 * Floor1.CellWidth
- Floor1.Angle = 0
- ' Set the colors of the walls, ceiling, and floor.
- Floor1.WallColorA = 7 ' White
- Floor1.WallColorB = 4 ' Red
- Floor1.CeilingColor = 11 ' Light Cyan
- Floor1.FloorColor = 2 ' Green
- Floor1.StripeColor = 0 ' Black
- ' Load the sprites.
- Floor1.SpritePath = Path
- Floor1.Sprite(65) = "TREE.BMP" ' 65 = ASCII of "A"
- Floor1.Sprite(66) = "LIGHT.BMP" ' 66 = ASCII of "B"
- Floor1.Sprite(67) = "EX1.BMP" ' 67 = ASCII of "C"
- Floor1.Sprite(68) = "EX2.BMP" ' 68 = ASCII OF "D"
- Floor1.Sprite(69) = "JOG1.BMP" ' 69 = ASCII OF "E"
- Floor1.Sprite(70) = "JOG2.BMP" ' 70 = ASCII OF "F"
- Floor1.Sprite(71) = "JOG3.BMP" ' 71 = ASCII OF "G"
- Floor1.Sprite(72) = "JOG4.BMP" ' 72 = ASCII OF "H"
- ' Set sprite number 66 (the Light sprite)
- ' as a soft sprite.
- ' (i.e. the user can walk through this sprite).
- Floor1.SetSpriteSoft (66)
- End Sub
- Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
- Static PrevX, PrevY
- ' If none of the mouse buttons is pressed down,
- ' terminate this procedure.
- If Button = 0 Then Exit Sub
- ' Change the user's position according to the
- ' mouse movement.
- If Y < PrevY Then Floor1.Advance 50
- If Y > PrevY Then Floor1.Advance -50
- If X < PrevX Then Floor1.Angle = Floor1.Angle + 3
- If X > PrevX Then Floor1.Angle = Floor1.Angle - 3
- ' Display the 3D view.
- Floor1.Display3D
- ' Update PrevX and PrevY for next time.
- PrevX = X
- PrevY = Y
- End Sub
- Private Sub Form_Paint()
- ' If the form is minimized, terminate this procedure.
- If Me.WindowState = 1 Then Exit Sub
- ' Display the 3D view.
- Floor1.Display3D
- End Sub
- Private Sub mnuAbout_Click()
- Dim Title
- Dim Msg
- Dim CR
- CR = Chr(13) + Chr(10)
- ' The title of the About message box.
- Title = "About the 3D Floor Program"
- ' Prepare the message of the About message box.
- Msg = "This program was written with Visual "
- Msg = Msg + "Basic for Windows, using the "
- Msg = Msg + "TegoSoft 3D Floor OCX control. "
- Msg = Msg + CR + CR
- Msg = Msg + "The TegoSoft 3D Floor OCX control "
- Msg = Msg + "is part of the TegoSoft OCX Control "
- Msg = Msg + "Kit - a collection of various OCX controls. "
- Msg = Msg + CR + CR
- Msg = Msg + "For more information about the "
- Msg = Msg + "TegoSoft OCX Control Kit, contact TegoSoft "
- Msg = Msg + "at:"
- Msg = Msg + CR + CR
- Msg = Msg + "TegoSoft Inc." + CR
- Msg = Msg + "P.O. Box 389" + CR
- Msg = Msg + "Bellmore, NY 11710"
- Msg = Msg + CR + CR
- Msg = Msg + "Phone: (516)783-4824"
- ' Display the About message box.
- MsgBox Msg, vbInformation, Title
- End Sub
- Private Sub mnuExit_Click()
- ' Terminate the program.
- Unload Me
- End Sub
- Private Sub Timer1_Timer()
- Static ExerciseFrame As Integer
- Static JoggerY As Integer
- Static JoggerFrame As Boolean
- ' If the form is minimized, terminate this procedure.
- If Me.WindowState = 1 Then Exit Sub
- ' Display the next frame of the exercising woman
- ' (inside the cell at coordinate x=10, y=40).
- ' Frame 0 of the exercising woman is sprite
- ' number 67. And frame 1 of the exercising woman is
- ' sprite number 68.
- If ExerciseFrame = 0 Then
- ExerciseFrame = 1
- Floor1.SetCell 10, 40, 67
- ExerciseFrame = 0
- Floor1.SetCell 10, 40, 68
- End If
- ' Set the cell of the previous jogger position
- ' to an empty cell.
- If JoggerY <> 0 Then
- Floor1.SetCell 23, JoggerY, 0
- End If
- ' If the jogger has reached the end of the hall,
- ' reset JoggerY to 0.
- If JoggerY = 48 Then
- JoggerY = 0
- End If
- ' Increment JoggerY.
- JoggerY = JoggerY + 1
- ' Set JoggerFrame to the next frame number.
- If (JoggerFrame = 0) Then
- JoggerFrame = 1
- JoggerFrame = 0
- End If
- ' If the user is facing the jogger, show the front
- ' of the jogger (sprites 69 and 70). Otherwise, show
- ' the back of the jogger (sprites 71 and 72).
- If Floor1.CellPosY >= JoggerY Then
- If JoggerFrame = 0 Then
- Floor1.SetCell 23, JoggerY, 69
- Else
- Floor1.SetCell 23, JoggerY, 70
- End If
- If JoggerFrame = 0 Then
- Floor1.SetCell 23, JoggerY, 71
- Else
- Floor1.SetCell 23, JoggerY, 72
- End If
- End If
- ' Display th 3D view.
- Floor1.Display3D
- End Sub
-